widget: Add a critical when allocation is too small.
authorBenjamin Otte <otte@redhat.com>
Wed, 9 Sep 2020 15:07:01 +0000 (17:07 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 9 Sep 2020 15:38:37 +0000 (17:38 +0200)
gtk/gtkwidget.c

index 18038fd1a466d929f0c97777010480923bce910a..01ea24da595dde2bbc1e623c6bca015620287cdf 100644 (file)
@@ -3785,6 +3785,28 @@ gtk_widget_allocate (GtkWidget    *widget,
                  "How does the code know the size to allocate?",
                  gtk_widget_get_name (widget), widget);
     }
+  if (!GTK_IS_SCROLLABLE (widget))
+    {
+      int min;
+      gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL, width, &min, NULL, NULL, NULL);
+      if (min > height)
+        {
+          g_critical ("Allocation height too small. Tried to allocate %dx%d, but %s %p needs "
+                      "at least %dx%d.",
+                      width, height,
+                      gtk_widget_get_name (widget), widget,
+                      width, min);
+        }
+      gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, height, &min, NULL, NULL, NULL);
+      if (min > width)
+        {
+          g_critical ("Allocation width too small. Tried to allocate %dx%d, but %s %p needs "
+                      "at least %dx%d.",
+                      width, height,
+                      gtk_widget_get_name (widget), widget,
+                      min, height);
+        }
+    }
 #endif /* G_ENABLE_DEBUG */
 
   alloc_needed = priv->alloc_needed;